/**
 * Initialize your data structure here.
 */
var MyStack = function () {
  this.data = new Array();
  this.help = new Array();

};

/**
* Push element x onto stack. 
* @param {number} x
* @return {void}
*/
MyStack.prototype.push = function (x) {
  this.data.push(x);
};

/**
* Removes the element on top of the stack and returns that element.
* @return {number}
*/
MyStack.prototype.pop = function () {
  if (this.data.length === 1) return this.data.shift();
  while (this.data.length > 1) {
    this.help.push(this.data.shift());
  }
  let tmp = this.data.shift();
  [this.data, this.help] = [this.help, this.data];
  return tmp;

};

/**
* Get the top element.
* @return {number}
*/
MyStack.prototype.top = function () {
  return this.data[this.data.length - 1];

};

/**
* Returns whether the stack is empty.
* @return {boolean}
*/
MyStack.prototype.empty = function () {
  if (this.data.length === 0) {
    return true
  } else {
    return false;
  }

};

/**
* Your MyStack object will be instantiated and called as such:
* var obj = new MyStack()
* obj.push(x)
* var param_2 = obj.pop()
* var param_3 = obj.top()
* var param_4 = obj.empty()
*/
